package com.yupi.springbootinit.model.enums;

/**
 * 工作流任务状态（与数据库字符串字段一致）
 */
public enum TaskStatus {
    PENDING("PENDING", "待处理"),
    IN_PROGRESS("IN_PROGRESS", "进行中"),
    DONE("DONE", "已完成");

    private final String code;
    private final String displayName;

    TaskStatus(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    public String code() {
        return code;
    }

    public String displayName() {
        return displayName;
    }

    public static TaskStatus from(String value) {
        if (value == null) return null;
        for (TaskStatus s : values()) {
            if (s.code.equalsIgnoreCase(value)) {
                return s;
            }
        }
        return null;
    }

    public static boolean isValid(String value) {
        return from(value) != null;
    }
}